package com.xmotor.test_httpclient;

import com.alibaba.fastjson.JSON;
import com.xmotor.test_httpclient.client.TestClient;
import com.xmotor.test_httpclient.model.UserBO;

import java.util.HashMap;

public class Test {
    public static void main(String[] args) {
        TestClient client = TestClient.getInstance("http://localhost:8080");

        System.out.println("测试get请求=====================");
        System.out.println(client.doGet("/test/testGet",new HashMap<String, String>(){
            {
                put("id",1+"");
                put("name","小明");
            }
        }));

        System.out.println("测试以form形式提交的post请求=====================");
        System.out.println(client.doPostForm("/test/testPostForm",new HashMap<String, String>(){
            {
                put("id",1+"");
                put("name","小王");
            }
        }));

        System.out.println("测试以json形式提交的post请求=====================");
        UserBO user = new UserBO().setId(2).setName("小东");
        System.out.println(client.doPostJson("/test/testPostJson", JSON.toJSONString(user)));


    }
}
